<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script>
window.onload=function(){
	var aBtn=document.getElementsByTagName('input');

	for(var i=0;i<aBtn.length;i++){
		aBtn[i].onclick=function(){

			alert(i);  //按钮的长度3  

       // aBtn[i].style.background='yellow';
//作用域 : 取决于var

       for (var i = 0; i < aBtn.length; i++) {
       	aBtn[i].style.background='yellow';
       }
		};
	}
};

</script>

</head>
<body>

<input type="button" value="按钮1"/>	
<input type="button" value="按钮2"/>	
<input type="button" value="按钮3"/>	

</body>
</html>